//导入模块
import { load } from "/code/web/util/LoadView.js"
//加载topbar
load()
async function render() {
    let id = new URL(location.href).searchParams.get('id')
    //获取数据
    // console.log(id)
    async function getData(id) {
        let res = await fetch(`http://localhost:3000/news?id=${id}`).then(res => res.json())
        console.log(res)
        document.querySelector(".box").innerHTML = res.map(item => {
            return ` <h2 class="title">${item.title}</h2>
            <div class="author">作者：${item.author}</div>
            <hr>
            <div class="content">${item.content}</div>`
        })
    }
    getData(id)
}
render()
